/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tardistv.utilities;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * This Class is suppossed to contain all the static useful methods related with networks.
 * @author Tardis TV Team
 */
public class Network {

    /**
     * This method downloads the source code of the specified Web Page
     * @param address The address of the Web Page
     * @return The source of the Web Page
     * @throws MalformedURLException If the address is incorrect
     * @throws IOException If it's impossible to get the Web Page
     */
    public static String HTMLSource(String address) throws MalformedURLException, IOException {
        DataInputStream dis;
        String line = "";
        String source = "";
        dis = new DataInputStream(new BufferedInputStream(new URL(address).openStream()));
        while ((line = dis.readLine()) != null) {
            source += line + '\n';
        }
        return source;
    }
}
